package com.bw.module_notice.adapter

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import com.baway.home.model.NoticeResult
import com.bumptech.glide.Glide
import com.bw.module_notice.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class NoticeAdapter:BaseQuickAdapter<NoticeResult,BaseViewHolder>(R.layout.item_notice) {
    override fun convert(holder: BaseViewHolder, item: NoticeResult) {
        val img = holder.getView<ImageView>(R.id.notice_img)

        if (item.title=="社区活动"){
            Glide.with(img).load(R.drawable.notice_03).into(img)
        }else if (item.title=="安全提醒"){
            Glide.with(img).load(R.drawable.notice_06).into(img)
        }else if (item.title=="环境维护"){
            Glide.with(img).load(R.drawable.notice_08).into(img)
        }

        holder.setText(R.id.notice_title,item.title)
        holder.setText(R.id.notice_time,item.publishTime)
        holder.setText(R.id.notice_context,item.content)
        holder.setText(R.id.notice_status,item.status)

        if (item.status=="立即报名"){
            holder.getView<TextView>(R.id.notice_status).setTextColor(Color.parseColor("#ffffff"))
            holder.getView<TextView>(R.id.notice_status).setBackgroundColor(Color.parseColor("#4086F4"))
        }else if (item.status=="已读"){
            holder.getView<TextView>(R.id.notice_status).setTextColor(Color.parseColor("#4086F4"))
            holder.getView<TextView>(R.id.notice_status).setBackgroundColor(Color.parseColor("#DBEAFE"))
        }else if (item.status=="未读"){
            holder.getView<TextView>(R.id.notice_status).setTextColor(Color.parseColor("#000000"))
            holder.getView<TextView>(R.id.notice_status).setBackgroundColor(Color.parseColor("#9CA3AF"))
        }
    }
}